﻿using System;
using System.Collections.Generic;
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using LFloatMath.Math;


namespace IQIGame.Onigao.Logic
{
    public class SkillActionNode : ISerializeByteBuf
    {
        public long guid;
        public int actionType;
        public SkillCustomConfig customConfig;

        public void Serialize(ByteBuf _buf)
        {
            _buf.WriteLong(this.guid);
            _buf.WriteInt(this.actionType);
            SerializeByteBufUtil.SerializeObject(_buf, this.customConfig);
        }

        public void DeSerialize(ByteBuf _buf)
        {
            this.guid = _buf.ReadLong();
            this.actionType = _buf.ReadInt();
            this.customConfig = SkillFactory.CreateActionConfig(this.actionType, _buf);
        }
    }

    public partial class SkillEffectiveAction_Damage_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamBool hit;
        public SkillEffectiveAction_ParamBool crit;
        public SkillEffectiveAction_ParamNum damage;
        public bool checkDead;
    }

    public partial class SkillEffectiveAction_Buff_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamNum buffID;
        public SkillEffectiveAction_ParamNum stack;
        public SkillEffectiveAction_ParamNum param;
        public bool remove;
    }

    public partial class SkillEffectiveAction_InsertSkill_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamNum skillID;
    }

    public partial class SkillEffectiveAction_ExtendBuffDuration_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamNum buffID;
        public SkillEffectiveAction_ParamNum extend;
    }

    public partial class SkillEffectiveAction_Cure_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamNum cure;
    }

    public partial class SkillEffectiveAction_CustomProperty_ConfigData : SkillCustomConfig
    {
        public int propertyKey;
        public string customKey;
        public SkillEffectiveAction_ParamNum value;
        public int type;
    }

    public partial class SkillEffectiveAction_RepalceBuffDotType_ConfigData : SkillCustomConfig
    {
        public int dotType;
    }

    public partial class SkillEffectiveAction_DamageTempModify_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamNum damageModify;
        public SkillEffectiveAction_ParamNum hurtModify;
    }
    
    public partial class SkillEffectiveAction_Summon_ConfigData : SkillCustomConfig
    {
        public int maxCount;
        public int monsterID;
        public int power;
        public int powerType;
        public List<int> attrCorr;

        public long posX;
        public long posY;

        public List<SummonAttrData> specialAttr;

        public class SummonAttrData : ISerializeByteBuf
        {
            public EAttributeTypeFlag attrType;
            public LFloat attrRate = LFloat.one;
            public int formula;

            public void Serialize(ByteBuf _buf)
            {
                _buf.WriteInt((int)this.attrType);
                _buf.WriteLong(attrRate._val);
                _buf.WriteInt(this.formula);
            }

            public void DeSerialize(ByteBuf _buf)
            {
                this.attrType = (EAttributeTypeFlag)_buf.ReadInt();
                this.attrRate = new LFloat(true, _buf.ReadLong());
                this.formula = _buf.ReadInt();
            }
        }
    }
    
    public partial class SkillEffectiveAction_PackageActionCondition_ConfigData : SkillCustomConfig
    {
        public SkillEffectiveAction_ParamBool condition;
        public List<SkillActionNode> trueActions;
        public List<SkillActionNode> falseActions;
    }
}